home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNOWY.ARJ / SNOWY.ASM < prev    next >
Assembly Source File  |  1994-12-28  |  12KB  |  410 lines

  1. ;" Da Elite snowy rain"
  2. ; Again another 2 day project
  3. ; We are busy coding our demo, but I still had time for this production.
  4. ; by LÖKÖ of Napalm Software
  5.  
  6. ; This 4K intro contains nothing really smashing or cool, but maybe someone
  7. ; finds this code useful. If so, we would really be happy if he could give
  8. ; us some greetings/credits. The zooming tricky is really neat hack.
  9. ; Program does not allocate any memory from DOS, but still uses 60000 bytes
  10. ; for the zoom!
  11.  
  12. ; As you propably know, there are many many places where you could easily
  13. ; squeeze some bytes off. But WHO CARES ABOUT TEN BYTES IN THESE DAYS OF
  14. ; GIGA WAREZ ?! Anyway there is some optimisation in this code.
  15.  
  16. ; Greetingz & other stuff:
  17. ;  -Juffo-WUP/Stealers?    Howya doing?
  18. ;  -Billy-boy/microsoft    WINDOWS SUCKS!
  19. ;  -MPS Labs               Smooth palette fading impossible for ya?
  20. ;  -Future Crew            Doing fine stuff
  21. ;  -Iguana                 Fine heartquake, !no design?
  22. ;  -Nordic Vision          .-.
  23. ;  -the rest
  24.  
  25. ; btw. The intro requires VGA & 286 compatible processor!
  26.  
  27. cseg            segment
  28.                 assume  cs:cseg
  29.                 org 100h
  30.                 .286
  31.  
  32. main:
  33.   ;*******Checka for 286 processor*******
  34.   push sp
  35.   pop  dx
  36.   cmp  dx,sp
  37.   jz   @was_it
  38.   lea  dx,no286
  39.   jmp  @displ_string
  40.   @was_it:
  41.   ; *****Check for VGA*******
  42.   mov  ax,01a00h
  43.   int  10h
  44.   cmp  al,01ah
  45.   jne  @dansi
  46.   cmp  bl,7
  47.   jb   @dansi
  48.  
  49.   ;*******System has 286 and VGA. Let's rock
  50.   call white_pal  ;Do a palette tricky
  51.   mov ax,13h
  52.   int 10h                                                      
  53.   call initsnow
  54.   mov ax,01130h   ;Load 8x8 font pointer
  55.   mov bh,3
  56.   int 10h
  57.   push es
  58.   pop  ds         ;Segments now inited.. DS points to font, ES points vidmem
  59.   push 0a000h
  60.   pop  es
  61.  
  62.   cld             ;Dangerous? in proper applications this should be done right
  63.                   ;before every MOVSB/MOVSW yms. intruction
  64.   @lopez:
  65.     call vertr
  66.  
  67.     cmp byte ptr cs:[offset temp_count],speedy
  68.     jle @no_text
  69.     call dotext
  70.     mov byte ptr cs:[offset temp_count],0
  71.     @no_text:
  72.     inc byte ptr cs:[offset temp_count]
  73.     call movesnow
  74.     call drawsnow
  75.     mov ah,1    ;Wait a keypress
  76.     int 16h
  77.     jz  @lopez
  78.  
  79.   ;Let's zoom the piccy away!
  80.   ;****Init zooming buffer****   
  81.                 push    es
  82.                 mov     cx,32000-2048
  83.                 xor     si,si
  84.                 mov     di,offset imagepointer
  85.                 push    0a000h
  86.                 pop     ds
  87.                 push    cs
  88.                 pop     es
  89.                 rep     movsw
  90.                 pop     es
  91.  
  92.   mov cx,200
  93.   @zloop:
  94.     call vertr
  95.     call teezoomi
  96.     loop @zloop
  97.  
  98.   ;Do a palette trick
  99.   call white_pal
  100.   mov ax,3h
  101.   int 10h
  102.   @dansi:
  103.   lea dx,endansi
  104.   @displ_string:                         ;Diz can be called from other places too!
  105.   push cs
  106.   pop  ds
  107.   mov ah,9
  108.   int 21h
  109.   ret                         ;This "exit to dos" works only with com files
  110.  
  111. ;RANDOM NUMBER GENERATOR
  112. ;IN:
  113. ;  CX=random number ranges
  114. ;OUT:
  115. ;  DX=random number
  116. random          proc    near
  117.                 push ax
  118.                 push bx
  119.                 mov ax,cs:[offset seed]
  120.                 mov bx,9821
  121.                 imul bx
  122.                 inc ax
  123.                 ror al,1
  124.                 add ax,8191
  125.                 rol ah,1
  126.                 mov cs:[offset seed],ax
  127.                       
  128.                 xor dx,dx
  129.                 div cx
  130.                 pop bx
  131.                 pop ax
  132.                 ret
  133.                 endp
  134.  
  135. dotext          proc    near             ;Make (lame) writer happen
  136.                 pusha
  137.                 mov si,cs:[offset char_counter]
  138.                 xor bh,bh
  139.                 mov bl,cs:[offset texte+si]   ;Character to displayed to BX
  140.                 shl bx,3
  141.                 add bp,bx                     ;BP points to character data
  142.  
  143.                 mov di,cs:[offset yplace]
  144.                 xor dx,dx
  145.                 mov ax,320
  146.                 mul di
  147.                 mov di,ax
  148.                 add di,cs:[offset xplace]     ;DI points to right place in vidmem
  149.  
  150.                 ;Display character
  151.                 mov cx,8                      ;Horizontal counter
  152.                 @horiz_loop:
  153.                 mov bx,8
  154.                 @vert_loop:
  155.                 mov dl,ds:[bp]
  156.                 mov al,1
  157.                 shl al,cl
  158.                 and dl,al
  159.                 jz  @ei_pikseli
  160.                 mov al,14
  161.                 mov es:[di],al
  162.                 @ei_pikseli:
  163.                 add di,320                ;Next row
  164.                 inc bp
  165.                 dec bx
  166.                 jnz @vert_loop
  167.                 sub di,320*8-1
  168.                 sub bp,8
  169.                 loop @horiz_loop
  170.  
  171.                 ;Update message counters
  172.                 inc word ptr cs:[offset char_counter]
  173.                 add word ptr cs:[offset xplace],9
  174.                 mov si,cs:[offset char_counter]
  175.                 cmp byte ptr cs:[offset texte+si],0            ;End of Line?
  176.                 jne @fake_alarm
  177.                 add word ptr cs:[offset char_Counter],2        ;Skip  "paska" data
  178.                 mov al,cs:[offset texte+si+1]
  179.                 xor ah,ah
  180.                 mov cs:[offset yplace],ax                      ;New coordinates
  181.                 mov word ptr cs:[offset xplace],20
  182.                 add si,2
  183.                 @fake_alarm:
  184.                 cmp byte ptr cs:[offset texte+si],1            ;End of Text?
  185.                 jne @fake_fake
  186.                 mov word ptr cs:[offset char_counter],1
  187.                 mov word ptr cs:[offset yplace],20
  188.                 @fake_fake:
  189.                 popa
  190.                 ret
  191.                 endp
  192.  
  193. movesnow        proc    near
  194.                 pusha
  195.                 xor bx,bx
  196.                 xor di,di
  197.                 @move_loop1:
  198.                 inc word ptr cs:[offset snowy+di+2]
  199.                 cmp word ptr cs:[offset snowy+di+2],180
  200.                 jle @not_yet                              ;Y coord. out of screen?
  201.                 mov word ptr cs:[offset snowy+di+2],0     ;Yes, clear Y
  202.                 mov cx,320                                ;Random X
  203.                 call random
  204.                 mov cs:[offset snowy+di],dx
  205.                 mov cx,3                                  ;Random color
  206.                 call random
  207.                 inc dx
  208.                 mov cs:[offset snoww+bx],dl
  209.                 @not_yet:
  210.  
  211.                 mov cx,2                                  ;Random X movement
  212.                 call random
  213.                 cmp dx,1
  214.                 jne @ei_oikea
  215.                 add word ptr cs:[offset snowy+di],2
  216.                 @ei_oikea:
  217.                 dec word ptr cs:[offset snowy+di]
  218.  
  219.                 add di,4
  220.                 inc bx
  221.                 cmp bx,snowcount
  222.                 jl  @move_loop1    ;Try JLE instead -)
  223.                 popa
  224.                 ret
  225.                 endp
  226.  
  227. drawsnow        proc    near
  228.                 pusha
  229.                 xor di,di
  230.                 mov bx,snowcount
  231.                 @draw_loop:
  232.                 mov si,320
  233.                 xor dx,dx
  234.                 mov ax,cs:[offset snowy+di+2]
  235.                 mul si
  236.                 mov si,ax
  237.                 add si,cs:[offset snowy+di]
  238.                 mov al,cs:[offset snoww+bx]
  239.                 add al,20
  240.                 mov es:[si],al
  241.                 add di,4
  242.                 dec bx
  243.                 jnz @draw_loop
  244.                 popa
  245.                 ret
  246.                 endp
  247.  
  248. initsnow        proc    near             ;Initialize snow array with random values
  249.                 pusha
  250.                 mov bx,snowcount
  251.                 xor di,di
  252.                 @loopi_joo:
  253.                 mov cx,320
  254.                 call random
  255.                 mov cs:[offset snowy+di],dx
  256.                 mov cx,200
  257.                 call random
  258.                 mov cs:[offset snowy+di+2],dx
  259.                 add di,4
  260.                 
  261.                 mov cx,3    ;Try disabling these four lines :=)
  262.                 call random
  263.                 inc dx
  264.                 mov cs:[offset snoww+bx],dl
  265.  
  266.                 dec bx
  267.                 jnz @loopi_joo
  268.                 popa
  269.                 ret
  270.                 endp
  271.  
  272. ;IN:
  273. ;  CX=zooming factor
  274. ;OUT:
  275. ;  none
  276. teezoomi        proc    near             ;Zoom the picture
  277.                 pusha
  278.  
  279.                 ;Calculate zooming buffer
  280.                 mov bx,180              ;For 180 vertical lines
  281.                 @zbcalc:
  282.                 mov byte ptr cs:[offset zbuffer+bx],0
  283.                 mov ax,bx
  284.                 xor dx,dx
  285.                 mul cx
  286.                 mov si,200
  287.                 div si
  288.                 cmp bp,ax
  289.                 je  @ei_piks
  290.                 inc byte ptr cs:[offset zbuffer+bx]
  291.                 @ei_piks:
  292.                 mov bp,ax
  293.                 dec bx
  294.                 jnz @zbcalc
  295.  
  296.                 ;Perform actual zooming
  297.                 mov di,100
  298.                 shr cx,1
  299.                 sub di,cx
  300.                 mov ax,320
  301.                 xor dx,dx
  302.                 mul di
  303.                 mov di,ax                     ;DI points vidmem
  304.  
  305.                 mov cx,160
  306.                 xor ax,ax
  307.                 rep stosw
  308.  
  309.                 mov si,offset imagepointer    ;SI points original image
  310.                 push cs
  311.                 pop ds                        ;DS=CS, DS:SI points orig. image
  312.                 mov bx,180
  313.                 @zoloop:
  314.                 cmp byte ptr cs:[offset zbuffer+bx],1   ;Draw horiz. line?
  315.                 jne @ei_viivaa                          ;NOT!
  316.                 mov cx,160
  317.                 push si
  318.                 rep movsw
  319.                 pop si
  320.                 @ei_viivaa:
  321.                 add si,320
  322.                 dec bx
  323.                 jnz @zoloop
  324.  
  325.                 mov cx,160
  326.                 xor ax,ax
  327.                 rep stosw
  328.                 popa
  329.                 ret
  330.                 endp
  331.  
  332. vertr           proc    near
  333.     push ax
  334.     push dx
  335.     mov dx,3dah         ;Wait Vertical Retrace
  336.     @vv1:
  337.     in al,dx
  338.     test al,8
  339.     jnz @vv1
  340.     @vv2:
  341.     in al,dx
  342.     test al,8
  343.     jz @vv2
  344.     pop  dx
  345.     pop  ax
  346.     ret
  347.     endp
  348.  
  349. white_pal       proc    near
  350.   pusha
  351.   ;Lame palette trick, but who cares?
  352.   mov dx,3c8h
  353.   xor ax,ax
  354.   out dx,al            ;Start from color 0
  355.   mov al,63
  356.   inc dx
  357.   @aga:
  358.   call vertr
  359.     mov cx,768
  360.     @onetime:
  361.     out dx,al
  362.     out dx,al
  363.     out dx,al
  364.     loop @onetime
  365.   dec al
  366.   jnz @aga
  367.   popa
  368.   ret
  369. white_pal       endp
  370.  
  371.   include endansi.raw                    ;Include ansi screen
  372.   endmarker     db 0dh,0ah,'$'
  373.  
  374.   no286         db 'NO i286!',0dh,0ah,'$'
  375.  
  376.   zbuffer       db  200 dup(0)           ;Buffer used for zooming
  377.  
  378.   ;************ After "rain" effect the following data is overwritten!! **********
  379.   imagepointer label byte
  380.  
  381.   ;*********** DATA ************
  382.   snowcount     EQU  400                 ; 400 "snowy" pixels
  383.   seed          dw   9821                ; Random number seed
  384.   
  385.   filler        db   3                   ; Make the file size exactly 4096 bytes=4KBs
  386.  
  387.   texte         label byte
  388.                 db   20,'Hia! Napalm Software codes again',0
  389.                 db   40,'After releasing Shade Bob intro',0
  390.                 db   50,'We are back in notime with this.',0
  391.                 db   185,'***** Intro code by LÖKÖ *****',0
  392.                 db   60,'Did someone say we are not fast?!',0
  393.                 db   80,'Greetingz JMP to ...',0
  394.                 db   90,'hehehe... We greet nobody ...',0
  395.                 db   100,'Just coz We rule and U don',39,'t',0
  396.                 db   140,'B happy, txt will repeat!',0,0,1
  397.  
  398.   speedy        EQU  8   ;Text will be advanced only each 8th frame
  399.   temp_count    db   0
  400.   char_counter  dw   1
  401.   xplace        dw   20
  402.   yplace        dw   20
  403.  
  404.   ;Using "?" instead of 0 is wise. You don't need any "POSTPROC.EXE"!
  405.   snowy         dw   snowcount*2 dup (?) ; Snow pixel coordinates
  406.   snoww         db   snowcount dup (?)   ; Snow pixel colors
  407.  
  408. cseg            ends                               
  409.                 end main
  410.